<template>
  <div id="Recommend" class="modelBox">
    <h2 class="title">
      <a href>
        <img src="../../../static/m_img/h_jx.png" alt>
        <span>精品推荐</span>
      </a>
      <a href='javascript:void(0)' @click="getCarList(6,'BuyCar','')" class="more">更多 ></a>
    </h2>
    <Row :gutter="10" class="recommendList" :style="{'margin-left':0,'margin-right':0}">
      <Col :span="12" v-for="(item,index) in recommendList" :key="index">
        <div class="list">
          <div class="grid-content">
            <a href='javascript:void(0)' @click="getCarDetail('CarDetail',item.id)" class="link" >
              <div class="carImgBg" :style="{backgroundImage:'url('+item.fileUrl+')'}"></div>
              <div class="carInfo">
                <p class="ellipsis-2">{{item.carModelName}}</p>
                <div class="priceCity">
                  <span class="price">{{(item.retailPrice/10000).toFixed(2)}}万</span>
                  <span class="city ellipsis-1">{{item.carCityName}}</span>
                </div>
              </div>
            </a>
          </div>
        </div>
      </Col>
    </Row>
  </div>
</template>
<script type="text/esmascript-6">
import { Row, Col } from "element-ui";
import { getReq,postReq } from "../../assets/js/api";
export default {
  data() {
    return {
      recommendList: [
      ]
    };
  },
  components: { Row, Col },
  methods: {
    // 获取推荐车辆
    getList(){
       getReq("/web/goods/queryGoodsForPrefecturePage", {
        prefectureType: 6,
        pageNum: 1,
        pageSize: 6
      }).then(res => {
        let { errcode, content, message } = res;
        if (errcode == 0) {
          this.recommendList = content.goodsInfo;
        } else {
          errorRes(errcode, message);
        }
      });
    },
    // 更多点击跳转车辆列表
     getCarList(id,name,seriesType ){
       this.$router.push({
        name: name,
        query: {
          id: id,
          seriesType:seriesType
        }
      })
    },
    // 点击跳转车辆详情
    getCarDetail(name,orderId){
       this.$router.push({
        name: name,
        query: {
          orderId: orderId
        }
      })
    }
  },
  mounted() {
    this.getList()
  }
};
</script>
<style type="text/css" lang='scss'>
#Recommend {
  background: #f4f6f8;
  padding: 0;
  h2 {
    display: flex;
    justify-content: space-between;
    border-bottom: 0px;
    align-items: center;
    background: #fff;
    padding: 0 15px;
    a.more {
      color: #0098ff;
      font-size: 1.166667rem;
    }
  }
  .recommendList {
    padding: 0 15px;
    margin-top: 10px;
    .list {
      background: #fff;
      box-shadow: 0px 0px 7.5px 0px rgba(0, 0, 0, 0.12);
      border-radius: 6px;
      margin-bottom: 7.5px;
      a {
        width: 100%;
      }
      .carImgBg {
        border-top-left-radius: 6px;
        border-top-right-radius: 6px;
      }
      .carInfo {
        padding: 7.5px;
        p {
          color: #303030;
          height: 30px;
          margin-bottom: 7.5px;
          line-height: 15px;
        }
        .priceCity {
          display: flex;
          justify-content: space-between;
          align-items: center;
          .price {
            color: #0098ff;
            font-size: 1.416667rem;
          }
          .city {
            color: #999;
            font-size: 0.916667rem;
            width: 40%;
            text-align: right;
          }
        }
      }
    }
  }
}
</style>